

import java.io.IOException;
import java.text.*;
import java.util.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import acme.*;
import acme.holders.*;

/**
 * Servlet implementation class GetPackages
 */
public class GetPackages extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GetPackages() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try
		{
			String from = request.getParameter("from");
			String to = request.getParameter("to");
		
			SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
		
			Date startDate = sdf.parse(request.getParameter("startDate"));
			Date returnDate = sdf.parse(request.getParameter("returnDate"));
			Calendar startCalendar = Calendar.getInstance();
			startCalendar.setTime(startDate);
			Calendar returnCalendar = Calendar.getInstance();
			startCalendar.setTime(returnDate);
			
			ACMESoapBindingStub stub = new ACMESoapBindingStub();
			GetFlightsResponseHolder flights = new GetFlightsResponseHolder();
			GetApartmentsResponseHolder apartments = new GetApartmentsResponseHolder();
			GetCarsResponseHolder cars = new GetCarsResponseHolder();
			stub.browse(from, to, startCalendar, returnCalendar, apartments, flights, cars);
			
			response.setContentType("text/plain");
			response.getWriter().write(from);
		}
		catch (Throwable ex)
		{
			response.getWriter().write(ex.getMessage());
		}
	}

}
